home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / xmsif140.zip / XMSTEST2.C < prev    next >
C/C++ Source or Header  |  1991-12-08  |  27KB  |  670 lines

  1. /***************************************************************************
  2. *   xmstest2.c                                                             *
  3. *   MODULE:  XMSIF                                                         *
  4. *   OS:      DOS                                                           *
  5. *   VERSION: 1.0                                                           *
  6. *   DATE:    12/08/91                                                      *
  7. *                                                                          *
  8. *   Copyright (c) 1991 James W. Birdsall. All Rights Reserved.             *
  9. *                                                                          *
  10. *   Requires xmsif.h, testutil.h, and xmstest.h to compile.                *
  11. *   Compiles under Borland C++ 2.0, Turbo C 2.0, or MSC 6.00A.             *
  12. *                                                                          *
  13. *   Regression test and example for XMSIF. See XMSTEST.C for more detail.  *
  14. *                                                                          *
  15. ***************************************************************************/
  16.  
  17. /*
  18. ** system includes <>
  19. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <dos.h>
  24. #include <string.h>
  25.  
  26.  
  27. /*
  28. ** custom includes ""
  29. */
  30.  
  31. #include "xmsif.h"
  32. #include "xmstest.h"
  33.  
  34. #include "testutil.h"
  35.  
  36.  
  37. /*
  38. ** local #defines
  39. */
  40.  
  41. /*
  42. ** misc: copyright strings, version macros, etc.
  43. */
  44.  
  45. /*
  46. ** typedefs
  47. */
  48.  
  49. /*
  50. ** global variables
  51. */
  52.  
  53. extern int testno;
  54. extern char *gblmsg;
  55.  
  56.  
  57. /*
  58. ** static globals
  59. */
  60.  
  61. /*
  62. ** function prototypes
  63. */
  64.  
  65. static void do_ncopy2_tests(void);
  66.  
  67.  
  68. /*
  69. ** functions
  70. */
  71.  
  72.  
  73. /***************************************************************************
  74. *   FUNCTION: DO_COPY_TESTS                                                *
  75. *                                                                          *
  76. *   DESCRIPTION:                                                           *
  77. *                                                                          *
  78. *       Dispatcher function for copy test functions.                       *
  79. *                                                                          *
  80. *   ENTRY:                                                                 *
  81. *                                                                          *
  82. *       None.                                                              *
  83. *                                                                          *
  84. *   EXIT:                                                                  *
  85. *                                                                          *
  86. *       Void.                                                              *
  87. *                                                                          *
  88. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  89. *                                                                          *
  90. ***************************************************************************/
  91. void do_copy_tests(void)
  92. {
  93.     do_ncopy1_tests();
  94.     do_ncopy2_tests();
  95.     do_icopy_tests();
  96.  
  97.     return;
  98. } /* end of do_copy_tests() */
  99.  
  100.  
  101. /***************************************************************************
  102. *   FUNCTION: DO_NCOPY2_TESTS  (STATIC)                                    *
  103. *                                                                          *
  104. *   DESCRIPTION:                                                           *
  105. *                                                                          *
  106. *       Tests normal copy functions (_XMMcopy() and macros).               *
  107. *                                                                          *
  108. *   ENTRY:                                                                 *
  109. *                                                                          *
  110. *       None.                                                              *
  111. *                                                                          *
  112. *   EXIT:                                                                  *
  113. *                                                                          *
  114. *       Void.                                                              *
  115. *                                                                          *
  116. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  117. *                                                                          *
  118. ***************************************************************************/
  119. static void do_ncopy2_tests(void)
  120. {
  121.     int handle;
  122.     unsigned char far *realbuf;
  123.     unsigned char far *guard1, far *guard2, far *guard3;
  124.     unsigned char far *testbuf;
  125.     unsigned char far *testbuf2;
  126.     int status;
  127.     unsigned long start, stop, total;
  128.     unsigned char huge *temp;
  129.     unsigned long loop;
  130.  
  131.     /* first, allocate some XMS to test with */
  132.     handle = XMMalloc(MINFREE);
  133.     weirdcodechk("XMMalloc", 0, (void far *) NULL, 0, 0);
  134.  
  135.     /* next, allocate a conventional memory buffer */
  136.     realbuf = (unsigned char far *) LMALLOC((MINFREE/1024L) + 3);
  137.     if (realbuf == (unsigned char far *) NULL)
  138.     {
  139.         printf("Can't allocate conventional buffer. Aborting.\n");
  140.         XMMfree(handle);
  141.         exit(3);
  142.     }
  143.  
  144.     /* set up guard zones, etc. */
  145.     guard1 = realbuf;
  146.     FMEMSET(guard1, GUARDVAL, 1024);
  147.     testbuf = (unsigned char far *) normptr(guard1 + 1024);
  148.     guard2 = (unsigned char far *) normptr(testbuf + HALFLEN);
  149.     FMEMSET(guard2, GUARDVAL, 1024);
  150.     testbuf2 = (unsigned char far *) normptr(guard2 + 1024);
  151.     guard3 = (unsigned char far *) normptr(testbuf2 + HALFLEN);
  152.     FMEMSET(guard3, GUARDVAL, 1024);
  153.  
  154.     /* set up patterns */
  155.     farincwordfill(testbuf, HALFLEN, 0);
  156.     FMEMSET(testbuf2, 0, HALFLEN);
  157.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  158.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  159.  
  160.  
  161.     /*
  162.     ** Now, try various copies to EMB, then copy HALFLEN of EMB back to
  163.     ** testbuf2 for checking.
  164.     */
  165.     gblmsg = "  COPY TESTS CONVENTIONAL-EMB";
  166.  
  167.     /* try an even-length copy from offset 0 to offset 0 */
  168.     TESTHEADER();
  169.     printf("XMMcopyto(): even-length copy from offset 0 to offset 0.\n");
  170.     printf("Should succeed.\n");
  171.     status = XMMcopyto(50, testbuf, handle, 0L);
  172.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  173.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  174.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  175.     SRCWORDCHECK(testbuf, HALFLEN);
  176.     GUARDCHECK(handle);
  177.     CPYWORDCHECK(testbuf2, 50);
  178.     ZEROCHECK((testbuf2 + 50), (HALFLEN - 50));
  179.     TESTTAILER();
  180.  
  181.     /* restore destination pattern */
  182.     FMEMSET(testbuf2, 0, HALFLEN);
  183.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  184.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  185.  
  186.     /* try an even-length copy from offset 0 to arbitrary offset */
  187.     TESTHEADER();
  188.     printf("XMMcopyto(): even-length copy from offset 0 to arbitrary offset.\n");
  189.     printf("Should succeed.\n");
  190.     status = XMMcopyto(50, testbuf, handle, 477L);
  191.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  192.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  193.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  194.     GUARDCHECK(handle);
  195.     SRCWORDCHECK(testbuf, HALFLEN);
  196.     ZEROCHECK(testbuf2, 477);
  197.     MEMCMP(testbuf, (testbuf2 + 477), 50);
  198.     ZEROCHECK((testbuf2 + 477 + 50), ((HALFLEN - 477) - 50));
  199.     TESTTAILER();
  200.  
  201.     /* restore destination pattern */
  202.     FMEMSET(testbuf2, 0, HALFLEN);
  203.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  204.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  205.  
  206.     /* try an even-length copy from offset 0 to just before the end */
  207.     TESTHEADER();
  208.     printf("XMMcopyto(): even-length copy from offset 0 to just before end.\n");
  209.     printf("Should succeed.\n");
  210.     status = XMMcopyto(50, testbuf, handle, (HALFLEN - 50));
  211.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  212.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  213.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  214.     GUARDCHECK(handle);
  215.     SRCWORDCHECK(testbuf, HALFLEN);
  216.     ZEROCHECK(testbuf2, (HALFLEN - 50));
  217.     CPYWORDCHECK((testbuf2 + HALFLEN - 50), 50);
  218.     TESTTAILER();
  219.  
  220.     /* restore destination pattern */
  221.     FMEMSET(testbuf2, 0, HALFLEN);
  222.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  223.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  224.  
  225.     /* try an even-length copy from arbitrary offset to arbitrary offset */
  226.     TESTHEADER();
  227.     printf("XMMcopyto(): even-length copy from arbitrary offset to ");
  228.     printf("arbitrary offset.\nShould succeed.");
  229.     status = XMMcopyto(50, (testbuf + 384), handle, 33333L);
  230.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  231.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  232.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  233.     GUARDCHECK(handle);
  234.     SRCWORDCHECK(testbuf, HALFLEN);
  235.     ZEROCHECK(testbuf2, 33333U);
  236.     MEMCMP((testbuf + 384), (testbuf2 + 33333U), 50);
  237.     ZEROCHECK((testbuf2 + 33333U + 50), ((HALFLEN - 33333U) - 50));
  238.     TESTTAILER();
  239.  
  240.     /* restore destination pattern */
  241.     FMEMSET(testbuf2, 0, HALFLEN);
  242.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  243.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  244.  
  245.     /* try an even-length copy from just before the end to arbitrary offset */
  246.     TESTHEADER();
  247.     printf("XMMcopyto(): even-length copy from just before end to arbitrary.\n");
  248.     printf("Should succeed.\n");
  249.     status = XMMcopyto(50, (testbuf+HALFLEN-50), handle, 7676L);
  250.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  251.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  252.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  253.     GUARDCHECK(handle);
  254.     SRCWORDCHECK(testbuf, HALFLEN);
  255.     ZEROCHECK(testbuf2, 7676);
  256.     MEMCMP((testbuf + HALFLEN - 50), (testbuf2 + 7676), 50);
  257.     ZEROCHECK((testbuf2 + 7676 + 50), ((HALFLEN - 7676) - 50));
  258.     TESTTAILER();
  259.  
  260.     /* restore destination pattern */
  261.     FMEMSET(testbuf2, 0, HALFLEN);
  262.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  263.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  264.  
  265.  
  266.     /* try an odd-length copy from offset 0 to offset 0 */
  267.     TESTHEADER();
  268.     printf("XMMcopyto(): odd-length copy from offset 0 to offset 0.\n");
  269.     printf("Should succeed.\n");
  270.     status = XMMcopyto(111, testbuf, handle, 0L);
  271.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  272.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  273.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  274.     GUARDCHECK(handle);
  275.     SRCWORDCHECK(testbuf, HALFLEN);
  276.     MEMCMP(testbuf, testbuf2, 111);
  277.     ZEROCHECK((testbuf2 + 111), (HALFLEN - 111));
  278.     TESTTAILER();
  279.  
  280.     /* restore destination pattern */
  281.     FMEMSET(testbuf2, 0, HALFLEN);
  282.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  283.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  284.  
  285.     /* try an odd-length copy from offset 0 to offset misc */
  286.     TESTHEADER();
  287.     printf("XMMcopyto(): odd-length copy from offset 0 to arbitrary offset.\n");
  288.     printf("Should succeed.\n");
  289.     status = XMMcopyto(111, testbuf, handle, 477L);
  290.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  291.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  292.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  293.     GUARDCHECK(handle);
  294.     SRCWORDCHECK(testbuf, HALFLEN);
  295.     ZEROCHECK(testbuf2, 477);
  296.     MEMCMP(testbuf, (testbuf2 + 477), 111);
  297.     ZEROCHECK((testbuf2 + 477 + 111), ((HALFLEN - 477) - 111));
  298.     TESTTAILER();
  299.  
  300.     /* restore destination pattern */
  301.     FMEMSET(testbuf2, 0, HALFLEN);
  302.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  303.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  304.  
  305.     /* try an odd-length copy from offset 0 to just before the end */
  306.     TESTHEADER();
  307.     printf("XMMcopyto(): odd-length copy from offset 0 to just before end.\n");
  308.     printf("Should succeed.\n");
  309.     status = XMMcopyto(111, testbuf, handle, (HALFLEN - 111));
  310.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  311.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  312.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  313.     GUARDCHECK(handle);
  314.     SRCWORDCHECK(testbuf, HALFLEN);
  315.     ZEROCHECK(testbuf2, (HALFLEN - 111));
  316.     MEMCMP(testbuf, (testbuf2 + HALFLEN - 111), 111);
  317.     TESTTAILER();
  318.  
  319.     /* restore destination pattern */
  320.     FMEMSET(testbuf2, 0, HALFLEN);
  321.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  322.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  323.  
  324.     /* try an odd-length copy from arbitrary offset to arbitrary offset */
  325.     TESTHEADER();
  326.     printf("XMMcopyto(): odd-length copy from arbitrary offset to ");
  327.     printf("arbitrary offset.\nShould succeed.\n");
  328.     status = XMMcopyto(111, (testbuf + 384), handle, 33333L);
  329.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  330.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  331.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  332.     GUARDCHECK(handle);
  333.     SRCWORDCHECK(testbuf, HALFLEN);
  334.     ZEROCHECK(testbuf2, 33333U);
  335.     MEMCMP((testbuf + 384), (testbuf2 + 33333U), 111);
  336.     ZEROCHECK((testbuf2 + 33333U + 111), ((HALFLEN - 33333U) - 111));
  337.     TESTTAILER();
  338.  
  339.     /* restore destination pattern */
  340.     FMEMSET(testbuf2, 0, HALFLEN);
  341.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  342.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  343.  
  344.     /* try an odd-length copy from just before the end to arbitrary offset */
  345.     TESTHEADER();
  346.     printf("XMMcopyto(): odd-length copy from just before end to arbitrary.\n");
  347.     printf("Should succeed.\n");
  348.     status = XMMcopyto(111, (testbuf + HALFLEN - 111), handle, 7676L);
  349.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  350.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  351.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  352.     GUARDCHECK(handle);
  353.     SRCWORDCHECK(testbuf, HALFLEN);
  354.     ZEROCHECK(testbuf2, 7676);
  355.     MEMCMP((testbuf + HALFLEN - 111), (testbuf2 + 7676), 111);
  356.     ZEROCHECK((testbuf2 + 7676 + 111), ((HALFLEN - 7676) - 111));
  357.     TESTTAILER();
  358.  
  359.     /* restore destination pattern */
  360.     FMEMSET(testbuf2, 0, HALFLEN);
  361.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  362.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  363.  
  364.  
  365.     /* try a one-byte copy from offset 0 to offset 0 */
  366.     TESTHEADER();
  367.     printf("XMMcopyto(): one-byte copy from offset 0 to offset 0.\n");
  368.     printf("Should succeed.\n");
  369.     status = XMMcopyto(1L, testbuf, handle, 0L);
  370.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  371.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  372.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  373.     GUARDCHECK(handle);
  374.     SRCWORDCHECK(testbuf, HALFLEN);
  375.     MEMCMP(testbuf, testbuf2, 1);
  376.     ZEROCHECK((testbuf2 + 1), (HALFLEN - 1));
  377.     TESTTAILER();
  378.  
  379.     /* restore destination pattern */
  380.     FMEMSET(testbuf2, 0, HALFLEN);
  381.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  382.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  383.  
  384.     /* try a one-byte copy from offset 0 to offset misc */
  385.     TESTHEADER();
  386.     printf("XMMcopyto(): one-byte copy from offset 0 to arbitrary offset.\n");
  387.     printf("Should succeed.\n");
  388.     status = XMMcopyto(1L, testbuf, handle, 477L);
  389.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  390.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  391.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  392.     GUARDCHECK(handle);
  393.     SRCWORDCHECK(testbuf, HALFLEN);
  394.     ZEROCHECK(testbuf2, 477);
  395.     MEMCMP(testbuf, (testbuf2 + 477), 1);
  396.     ZEROCHECK((testbuf2 + 477 + 1), ((HALFLEN - 477) - 1));
  397.     TESTTAILER();
  398.  
  399.     /* restore destination pattern */
  400.     FMEMSET(testbuf2, 0, HALFLEN);
  401.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  402.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  403.  
  404.     /* try a one-byte copy from offset 0 to just before the end */
  405.     TESTHEADER();
  406.     printf("XMMcopyto(): one-byte copy from offset 0 to just before end.\n");
  407.     printf("Should succeed.\n");
  408.     status = XMMcopyto(1L, testbuf, handle, (HALFLEN - 1));
  409.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  410.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  411.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  412.     GUARDCHECK(handle);
  413.     SRCWORDCHECK(testbuf, HALFLEN);
  414.     ZEROCHECK(testbuf2, (HALFLEN - 1));
  415.     MEMCMP(testbuf, (testbuf2 + HALFLEN - 1), 1);
  416.     TESTTAILER();
  417.  
  418.     /* restore destination pattern */
  419.     FMEMSET(testbuf2, 0, HALFLEN);
  420.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  421.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  422.  
  423.     /* try a one-byte copy from arbitrary offset to arbitrary offset */
  424.     TESTHEADER();
  425.     printf("XMMcopyto(): one-byte copy from arbitrary offset to ");
  426.     printf("arbitrary offset.\nShould succeed.");
  427.     status = XMMcopyto(1L, (testbuf + 384), handle, 33333L);
  428.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  429.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  430.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  431.     GUARDCHECK(handle);
  432.     SRCWORDCHECK(testbuf, HALFLEN);
  433.     ZEROCHECK(testbuf2, 33333U);
  434.     MEMCMP((testbuf + 384), (testbuf2 + 33333U), 1);
  435.     ZEROCHECK((testbuf2 + 33333U + 1), ((HALFLEN - 33333U) - 1));
  436.     TESTTAILER();
  437.  
  438.     /* restore destination pattern */
  439.     FMEMSET(testbuf2, 0, HALFLEN);
  440.     status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
  441.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  442.  
  443.     /* try a one-byte copy from just before the end to arbitrary offset */
  444.     TESTHEADER();
  445.     printf("XMMcopyto(): one-byte copy from just before end to arbitrary.\n");
  446.     printf("Should succeed.\n");
  447.     status = XMMcopyto(1L, (testbuf + HALFLEN - 1), handle, 7676L);
  448.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  449.     status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
  450.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  451.     GUARDCHECK(handle);
  452.     SRCWORDCHECK(testbuf, HALFLEN);
  453.     ZEROCHECK(testbuf2, 7676);
  454.     MEMCMP((testbuf + HALFLEN - 1), (testbuf2 + 7676), 1);
  455.     ZEROCHECK((testbuf2 + 7676 + 1), ((HALFLEN - 7676) - 1));
  456.     TESTTAILER();
  457.  
  458.  
  459.     /*
  460.     ** Try some copies with bad offsets, etc., just to make sure _XMMcopy()
  461.     ** is passing along error data from driver OK. _XMMcopy() does no
  462.     ** size checking on its own because it has no idea what the size of
  463.     ** the block is.
  464.     */
  465.     gblmsg = "  COPY TESTS CONVENTIONAL-EMB ERRORS";
  466.  
  467.     /* try a copy to a bad offset */
  468.     TESTHEADER();
  469.     printf("XMMcopyto(): copying to bad offset.\n");
  470.     printf("Should fail.\n");
  471.     status = XMMcopyto(50L, testbuf, handle, (MINFREE + 1L));
  472.     nofailcheck("XMMcopyto()", status, (void far *) realbuf, handle, 0);
  473.     weirdretchk("XMMcopyto()", status, (void far *) realbuf, handle, 0);
  474.     weirdcodechk("XMMcopyto()", XMM_BADDESTOFF, (void far *) realbuf,handle,0);
  475.     SRCWORDCHECK(testbuf, HALFLEN);
  476.     TESTTAILER();
  477.  
  478.     /* try a copy with an excessively long length */
  479.     TESTHEADER();
  480.     printf("XMMcopyto(): copying a block that runs off end of EMB.\n");
  481.     printf("Should fail.\n");
  482.     status = XMMcopyto((MINFREE + 1L), realbuf, handle, 0L);
  483.     nofailcheck("XMMcopyto()", status, (void far *) realbuf, handle, 0);
  484.     weirdretchk("XMMcopyto()", status, (void far *) realbuf, handle, 0);
  485.     weirdcodechk("XMMcopyto()", XMM_BADLENGTH, (void far *) realbuf, handle,0);
  486.     SRCWORDCHECK(testbuf, HALFLEN);
  487.     TESTTAILER();
  488.  
  489.  
  490.     /*
  491.     ** Now, let's do some speed tests (and make sure that we can handle
  492.     ** blocks > 64K). We're going to have to write over the middle
  493.     ** guard block to do it, and move the upper guard block.
  494.     */
  495.     gblmsg = "  COPY TESTS CONVENTIONAL-EMB SPEED";
  496.  
  497.     guard2 = (unsigned char far *) normptr(testbuf2 + HALFLEN - 1024);
  498.     FMEMSET(guard2, GUARDVAL, 1024);
  499.     LFMEMSET(testbuf, 0, MINFREE);
  500.     status = XMMcopyto(MINFREE, testbuf, handle, 0L);
  501.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  502.     lfarincwordfill(testbuf, MINFREE, 0);
  503.  
  504.     /* first, copy MINFREE bytes straight */
  505.     TESTHEADER();
  506.     printf("XMMcopyto(): copy %lu bytes as a block.\n", MINFREE);
  507.     printf("Should succeed.\n");
  508.     start = get_tick();
  509.     status = XMMcopyto(MINFREE, testbuf, handle, 0L);
  510.     stop = get_tick();
  511.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  512.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  513.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  514.     {
  515.         printf("Copy corrupted guard buffers.\n");
  516.         XMMfree(handle);
  517.         LFREE(realbuf);
  518.         exit(3);
  519.     }
  520.     status = XMMcopyfrom(MINFREE, handle, 0L, testbuf);
  521.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  522.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  523.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  524.     {
  525.         printf("Copy corrupted guard buffers.\n");
  526.         XMMfree(handle);
  527.         LFREE(realbuf);
  528.         exit(3);
  529.     }
  530.     CPYWORDCHECK(testbuf, MINFREE);
  531.     printf("Succeeded. Took %lu ticks.\n", (stop - start));
  532.     TESTTAILER();
  533.  
  534.     /* restore patterns */
  535.     LFMEMSET(testbuf, 0, MINFREE);
  536.     status = XMMcopyto(MINFREE, testbuf, handle, 0L);
  537.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  538.     lfarincwordfill(testbuf, MINFREE, 0);
  539.  
  540.     /* now, copy MINFREE bytes by words */
  541.     TESTHEADER();
  542.     printf("XMMcopyto(): copy %lu bytes by words.\n", MINFREE);
  543.     printf("Should succeed.\n");
  544.     total = 0L;
  545.     temp = (unsigned char huge *) testbuf;
  546.     for (loop = 0; loop < MINFREE; loop += 2L, temp += 2)
  547.     {
  548.         start = get_tick();
  549.         status = XMMcopyto(2L, temp, handle, loop);
  550.         stop = get_tick();
  551.         total += (stop - start);
  552.         TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  553.     }
  554.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  555.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  556.     {
  557.         printf("Copy corrupted guard buffers.\n");
  558.         XMMfree(handle);
  559.         LFREE(realbuf);
  560.         exit(3);
  561.     }
  562.     status = XMMcopyfrom(MINFREE, handle, 0L, testbuf);
  563.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  564.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  565.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  566.     {
  567.         printf("Copy corrupted guard buffers.\n");
  568.         XMMfree(handle);
  569.         LFREE(realbuf);
  570.         exit(3);
  571.     }
  572.     CPYWORDCHECK(testbuf, MINFREE);
  573.     printf("Succeeded. Took %lu ticks.\n", total);
  574.     TESTTAILER();
  575.  
  576.     /* restore patterns */
  577.     LFMEMSET(testbuf, 0, MINFREE);
  578.     status = XMMcopyto(MINFREE, testbuf, handle, 0L);
  579.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  580.     lfarincwordfill(testbuf, MINFREE, 0);
  581.  
  582.     /* now, copy MINFREE bytes by fives */
  583.     TESTHEADER();
  584.     printf("XMMcopyto(): copy %lu bytes by groups of five bytes.\n", MINFREE);
  585.     printf("Should succeed.\n");
  586.     total = 0L;
  587.     temp = (unsigned char huge *) testbuf;
  588.     for (loop = 0; loop < MINFREE; loop += 5L, temp += 5)
  589.     {
  590.         start = get_tick();
  591.         status = XMMcopyto(5L, temp, handle, loop);
  592.         stop = get_tick();
  593.         total += (stop - start);
  594.         TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  595.     }
  596.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  597.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  598.     {
  599.         printf("Copy corrupted guard buffers.\n");
  600.         XMMfree(handle);
  601.         LFREE(realbuf);
  602.         exit(3);
  603.     }
  604.     status = XMMcopyfrom(MINFREE, handle, 0L, testbuf);
  605.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  606.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  607.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  608.     {
  609.         printf("Copy corrupted guard buffers.\n");
  610.         XMMfree(handle);
  611.         LFREE(realbuf);
  612.         exit(3);
  613.     }
  614.     CPYWORDCHECK(testbuf, MINFREE);
  615.     printf("Succeeded. Took %lu ticks.\n", total);
  616.     TESTTAILER();
  617.  
  618.     /* restore patterns */
  619.     LFMEMSET(testbuf, 0, MINFREE);
  620.     status = XMMcopyto(MINFREE, testbuf, handle, 0L);
  621.     TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  622.     lfarincwordfill(testbuf, MINFREE, 0);
  623.  
  624.     /* now, copy MINFREE bytes by single bytes */
  625.     TESTHEADER();
  626.     printf("XMMcopyto(): copy %lu bytes individually.\n", MINFREE);
  627.     printf("Should succeed.\n");
  628.     total = 0L;
  629.     temp = (unsigned char huge *) testbuf;
  630.     for (loop = 0; loop < MINFREE; loop++, temp++)
  631.     {
  632.         start = get_tick();
  633.         status = XMMcopyto(1L, temp, handle, loop);
  634.         stop = get_tick();
  635.         total += (stop - start);
  636.         TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
  637.     }
  638.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  639.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  640.     {
  641.         printf("Copy corrupted guard buffers.\n");
  642.         XMMfree(handle);
  643.         LFREE(realbuf);
  644.         exit(3);
  645.     }
  646.     status = XMMcopyfrom(MINFREE, handle, 0L, testbuf);
  647.     TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
  648.     if ((farmemcheck(guard1, 1024, GUARDVAL) != 0) ||
  649.         (farmemcheck(guard2, 1024, GUARDVAL) != 0))
  650.     {
  651.         printf("Copy corrupted guard buffers.\n");
  652.         XMMfree(handle);
  653.         LFREE(realbuf);
  654.         exit(3);
  655.     }
  656.     CPYWORDCHECK(testbuf, MINFREE);
  657.     printf("Succeeded. Took %lu ticks.\n", total);
  658.     TESTTAILER();
  659.  
  660.  
  661.     /*
  662.     ** Clean up.
  663.     */
  664.     LFREE(realbuf);
  665.     test_XMMfree(handle);
  666.  
  667.     return;
  668. } /* end of static do_ncopy2_tests() */
  669.  
  670.